﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:Sample.ViewModels;assembly=Sample.ViewModels"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="WPF.Views.SynchronizeObject"
        Title="SynchronizeObject" Height="300" Width="500">
	<Window.Resources>
		<Storyboard x:Key="AlertStoryboard">
			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
				<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
				<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Visible}"/>
				<DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{x:Static Visibility.Hidden}"/>
			</ObjectAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border">
				<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
				<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.1"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</Window.Resources>
    <Window.DataContext>
        <vm:SynchronizeObjectViewModel />
    </Window.DataContext>
	<i:Interaction.Triggers>
		<i:EventTrigger EventName="PropertyChanged" SourceObject="{Binding AlertMessage, Mode=OneWay}">
			<ei:ControlStoryboardAction Storyboard="{StaticResource AlertStoryboard}"/>
		</i:EventTrigger>
	</i:Interaction.Triggers>
	<Grid>
		<StackPanel>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition />
					<RowDefinition />
					<RowDefinition />
				</Grid.RowDefinitions>
				<!-- INPC is INotifyPropertyChanged -->
				<TextBlock Grid.Column="0" Grid.Row="0"><Run Text="(INPC)TwoWay"/></TextBlock>
				<TextBox  Grid.Column="1" Grid.Row="0"
					Text="{Binding TwoWay.Value, Mode=TwoWay}"/>
				<TextBlock Grid.Column="0" Grid.Row="1"><Run Text="(INPC)OneWay"/></TextBlock>
				<TextBox  Grid.Column="1" Grid.Row="1"
					Text="{Binding OneWay.Value, Mode=TwoWay}"/>
				<TextBlock Grid.Column="0" Grid.Row="2"><Run Text="OneWayToSource"/></TextBlock>
				<TextBox  Grid.Column="1" Grid.Row="2"
					Text="{Binding OneWayToSource.Value, Mode=TwoWay}"/>
			</Grid>
			<Button Command="{Binding CheckCommand}" Content="Check Model's Value"/>
		</StackPanel>
		<Border x:Name="border" BorderBrush="Black" BorderThickness="1" Background="#FFFFA8A8" Visibility="Hidden" Opacity="0">
			<TextBlock Margin="0" TextWrapping="Wrap" Text="{Binding AlertMessage.Value}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
		</Border>
	</Grid>
</Window>
